home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / usenet / volume2 / mines.shr < prev    next >
Encoding:
Internet Message Format  |  1987-11-20  |  38.9 KB

  1. Path: uunet!husc6!mit-eddie!uw-beaver!tektronix!tekgen!tekred!games-request
  2. From: games-request@tekred.TEK.COM
  3. Newsgroups: comp.sources.games
  4. Subject: v02i090:  mines - minefield game for Suns
  5. Message-ID: <1845@tekred.TEK.COM>
  6. Date: 19 Nov 87 18:30:32 GMT
  7. Sender: billr@tekred.TEK.COM
  8. Lines: 1229
  9. Approved: billr@tekred.TEK.COM
  10.  
  11. Submitted by: tc.fluke.COM!toma@uw-beaver (Tom Anderson)
  12. Comp.sources.games: Volume 2, Issue 90
  13. Archive-name: mines.shr
  14.  
  15.  
  16. #! /bin/sh
  17. # This is a shell archive.  Remove anything before this line, then unpack
  18. # it by saving it into a file and typing "sh file".  To overwrite existing
  19. # files, type "sh file -c".  You can also feed this as standard input via
  20. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  21. # will see the following message at the end:
  22. #        "End of shell archive."
  23. # Contents:  README Makefile blackSquare.icon board.c boardsw.c
  24. #   crosshairs.cursor levelsw.c main.c mineSquare.icon mines.h
  25. #   mines.icon msgsw.c playerSquare.icon safeSquare.icon tool.c
  26. #   whiteSquare.icon
  27. # Wrapped by billr@tekred on Thu Nov 19 10:28:11 1987
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f README -a "${1}" != "-c" ; then 
  30.   echo shar: Will not over-write existing file \"README\"
  31. else
  32. echo shar: Extracting \"README\" \(1878 characters\)
  33. sed "s/^X//" >README <<'END_OF_README'
  34. XHere are the sources for the mines game.  I hacked this up from the chess
  35. Xtool - you might recognize the lineage.  I've been too lazy to write a 
  36. Xmanual page for it; however, it's pretty simple:
  37. X
  38. XTop Subwindow (the "level" subwindow): Controls how many mines are hidden
  39. Xin the array.  To change the level, just type a decimal number in this
  40. Xwindow and hit return.  Typing return by itself will start a new game
  41. Xat the same level as the previous one.  No path is guaranteed to exist;
  42. Xhowever, the game is unplayable above about 80 mines or so, and at this
  43. Xlevel the lack of a path is rare enough to not be frustrating.
  44. X
  45. XMiddle Subwindow (the "clairvoyance" subwindow):  Tells you how many 
  46. Xmines are in immediately adjacent squares (including diagonals).  The
  47. Xtop left four squares are always guaranteed to be free of mines.
  48. X
  49. XBottom Subwindow (the "minefield" subwindow):  The object is to get from 
  50. Xthe upper left square to the lower right square without being blown up.
  51. XClick:
  52. X    - the left mouse button on any adjacent square to move there.  
  53. X    Squares that you have occupied are highlighted.
  54. X
  55. X    - the middle mouse button on any square to mark the square as
  56. X    "dangerous".  Once the square is marked as dangerous, you 
  57. X    cannot accidentally move there.
  58. X
  59. X    - the right mouse button on any square to mark the square as 
  60. X     "safe".  This has no effect on your ability to move on the square,
  61. X    but eliminates the need to keep a separate piece of paper around
  62. X    or to have an excessively high IQ.
  63. X
  64. XThe middle and right mouse buttons are "toggles" - that is, clicking on
  65. Xa square again toggles the square's designation or changes its type (i.e.,
  66. Xfrom "safe" to "dangerous").  Both have no effect on squares you have
  67. Xalready occupied.
  68. X
  69. XTom Anderson, (206) 356-5895
  70. XJohn Fluke Mfg. Co., Inc.,  P.O. Box C9090 M/S 245F, Everett, Wa. 98206
  71. X{ hplsla, microsoft, uw-beaver, sun, tikal }!fluke!toma
  72. END_OF_README
  73. if test 1878 -ne `wc -c <README`; then
  74.     echo shar: \"README\" unpacked with wrong size!
  75. fi
  76. # end of overwriting check
  77. fi
  78. if test -f Makefile -a "${1}" != "-c" ; then 
  79.   echo shar: Will not over-write existing file \"Makefile\"
  80. else
  81. echo shar: Extracting \"Makefile\" \(676 characters\)
  82. sed "s/^X//" >Makefile <<'END_OF_Makefile'
  83. X#
  84. X# Makefile for nchess package.
  85. X#
  86. X
  87. XOBJS = board.o boardsw.o levelsw.o main.o msgsw.o tool.o
  88. XSRCS = board.c boardsw.c levelsw.c main.c msgsw.c tool.c
  89. XHDRS = mines.h
  90. XICONS = blackSquare.icon whiteSquare.icon mineSquare.icon mines.icon \
  91. X    playerSquare.icon safeSquare.icon
  92. XCURSORS = crosshairs.cursor
  93. X
  94. X#CFLAGS = -g
  95. XCFLAGS = -O
  96. X
  97. Xmines : $(OBJS)
  98. X    cc $(CFLAGS) -o mines $(OBJS) -lsuntool -lsunwindow -lpixrect
  99. X
  100. Xlint : $(SRCS) $(HDRS)
  101. X    lint $(SRCS)
  102. X
  103. Xlist : $(SRCS) $(HDRS)
  104. X    lpr -x2 -p -J"mines" *.h *.c
  105. X
  106. Xclean : 
  107. X    rm -f *.o mines
  108. X
  109. X$(OBJS) : $(HDRS)
  110. X
  111. Xshar : dist.sh
  112. X
  113. Xdist.sh : Makefile $(HDRS) $(SRCS) $(ICONS) $(CURSORS)
  114. X    shar Makefile $(HDRS) $(SRCS) $(ICONS) $(CURSORS) > dist.sh
  115. END_OF_Makefile
  116. if test 676 -ne `wc -c <Makefile`; then
  117.     echo shar: \"Makefile\" unpacked with wrong size!
  118. fi
  119. # end of overwriting check
  120. fi
  121. if test -f blackSquare.icon -a "${1}" != "-c" ; then 
  122.   echo shar: Will not over-write existing file \"blackSquare.icon\"
  123. else
  124. echo shar: Extracting \"blackSquare.icon\" \(1933 characters\)
  125. sed "s/^X//" >blackSquare.icon <<'END_OF_blackSquare.icon'
  126. X/* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16
  127. X */
  128. X    0xFFFF,0x0000,0x0000,0x0000,0x8001,0x0000,0x0000,0x0000,
  129. X    0xAAA9,0x0000,0x0000,0x0000,0x9555,0x0000,0x0000,0x0000,
  130. X    0xAAA9,0x0000,0x0000,0x0000,0x9555,0x0000,0x0000,0x0000,
  131. X    0xAAA9,0x0000,0x0000,0x0000,0x9555,0x0000,0x0000,0x0000,
  132. X    0xAAA9,0x0000,0x0000,0x0000,0x9555,0x0000,0x0000,0x0000,
  133. X    0xAAA9,0x0000,0x0000,0x0000,0x9555,0x0000,0x0000,0x0000,
  134. X    0xAAA9,0x0000,0x0000,0x0000,0x9555,0x0000,0x0000,0x0000,
  135. X    0x8001,0x0000,0x0000,0x0000,0xFFFF,0x0000,0x0000,0x0000,
  136. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  137. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  138. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  139. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  140. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  141. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  142. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  143. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  144. X    0x0000,0x0000,0xFFFF,0xFFFF,0x0000,0x0000,0x8000,0x0001,
  145. X    0x0000,0x0000,0xAAAA,0xAAA9,0x0000,0x0000,0x9555,0x5555,
  146. X    0x0000,0x0000,0xAAAA,0xAAA9,0x0000,0x0000,0x9555,0x5555,
  147. X    0x0000,0x0000,0xAAAA,0xAAA9,0x0000,0x0000,0x9555,0x5555,
  148. X    0x0000,0x0000,0xAAAA,0xAAA9,0x0000,0x0000,0x9555,0x5555,
  149. X    0x0000,0x0000,0xAAAA,0xAAA9,0x0000,0x0000,0x9555,0x5555,
  150. X    0x0000,0x0000,0xAAAA,0xAAA9,0x0000,0x0000,0x9555,0x5555,
  151. X    0x0000,0x0000,0xAAAA,0xAAA9,0x0000,0x0000,0x9555,0x5555,
  152. X    0x0000,0x0000,0xAAAA,0xAAA9,0x0000,0x0000,0x9555,0x5555,
  153. X    0x0000,0x0000,0xAAAA,0xAAA9,0x0000,0x0000,0x9555,0x5555,
  154. X    0x0000,0x0000,0xAAAA,0xAAA9,0x0000,0x0000,0x9555,0x5555,
  155. X    0x0000,0x0000,0xAAAA,0xAAA9,0x0000,0x0000,0x9555,0x5555,
  156. X    0x0000,0x0000,0xAAAA,0xAAA9,0x0000,0x0000,0x9555,0x5555,
  157. X    0x0000,0x0000,0xAAAA,0xAAA9,0x0000,0x0000,0x9555,0x5555,
  158. X    0x0000,0x0000,0xAAAA,0xAAA9,0x0000,0x0000,0x9555,0x5555,
  159. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0xFFFF,0xFFFF
  160. END_OF_blackSquare.icon
  161. if test 1933 -ne `wc -c <blackSquare.icon`; then
  162.     echo shar: \"blackSquare.icon\" unpacked with wrong size!
  163. fi
  164. # end of overwriting check
  165. fi
  166. if test -f board.c -a "${1}" != "-c" ; then 
  167.   echo shar: Will not over-write existing file \"board.c\"
  168. else
  169. echo shar: Extracting \"board.c\" \(4101 characters\)
  170. sed "s/^X//" >board.c <<'END_OF_board.c'
  171. X/*
  172. X * manage the board state
  173. X *
  174. X * Copyright (c) 1987 Tom Anderson; 20831 Frank Waters Road;
  175. X * Stanwood, WA  98282.   All rights reserved.
  176. X */
  177. Xstatic char copyright[] = "Copyright 1987 Tom Anderson";
  178. X
  179. X#include <stdio.h>
  180. X#include <strings.h>
  181. X#include <sys/types.h>
  182. X
  183. X#include "mines.h"
  184. X
  185. XSquare MainBoard[SIDE_SIZE][SIDE_SIZE];
  186. XBoardCoordinate PlayerLocation;
  187. XBOOL GameOver;
  188. X
  189. X/*
  190. X * set up the playing surface at the beginning of the game
  191. X */
  192. Xvoid
  193. XInitBoard(level)
  194. X    int level;            /* number of mines */
  195. X{
  196. X    register int i, j, minesPlaced, cutoff;
  197. X    register Square * sqp;
  198. X    int pass = 0;
  199. X    BOOL connected;
  200. X
  201. X    /* 
  202. X     * retry mine placement until a route can be had from the entry to
  203. X     * the exit (this needs work)
  204. X     */
  205. X    do {
  206. X    /*
  207. X     * zero the board 
  208. X     */
  209. X    for (i = 0 ; i < SIDE_SIZE ; i++) {
  210. X        for (j = 0 ; j < SIDE_SIZE ; j++) {
  211. X        sqp = &MainBoard[i][j];
  212. X        sqp->traversed = sqp->mined = sqp->occupied 
  213. X            = sqp->unsafe = sqp->safe = FALSE;
  214. X        }
  215. X    }
  216. X    /*
  217. X     * make several passes over the board, placing mines at
  218. X     * a probability calculated to require about 3 passes on the average
  219. X     */
  220. X    cutoff = level / 3 + 1;
  221. X    for (minesPlaced = 0 ; minesPlaced < level ; ) {
  222. X        for (i = 0 ; i < SIDE_SIZE ; i++) {
  223. X        for (j = 0 ; j < SIDE_SIZE ; j++) {
  224. X            if ((random() % (SIDE_SIZE * SIDE_SIZE)) < cutoff
  225. X            && ! MainBoard[i][j].mined
  226. X            && minesPlaced < level
  227. X            && ! (i <= 1 && j <= 1)
  228. X            && ! (i == SIDE_SIZE-1 && j == SIDE_SIZE-1)) {
  229. X            MainBoard[i][j].mined = TRUE;
  230. X            minesPlaced++;
  231. X            }
  232. X        }
  233. X        }
  234. X    }
  235. X    connected = TRUE;    /* ignore impossible mazes for now */
  236. X    } while ( ! connected);
  237. X    PlayerLocation.x = PlayerLocation.y = 0;
  238. X    MainBoard[0][0].occupied = MainBoard[0][0].traversed = TRUE;
  239. X    GameOver = FALSE;
  240. X}
  241. X
  242. X/*
  243. X * describe the state of the board square at x, y
  244. X */
  245. XSquare *
  246. XGetSquare(bloc)
  247. X    BoardCoordinate * bloc;
  248. X{
  249. X    return (&MainBoard[bloc->y][bloc->x]);
  250. X}
  251. X
  252. X/*
  253. X * toggle a square's marking as being probably safe or unsafe
  254. X */
  255. Xvoid
  256. XMarkSquare(suspect, safe)
  257. X    BoardCoordinate * suspect;
  258. X    BOOL safe;
  259. X{
  260. X    register Square * sqp = &MainBoard[suspect->y][suspect->x];
  261. X
  262. X    if (sqp->traversed)
  263. X    return;
  264. X    if (safe) {
  265. X    sqp->safe = ! sqp->safe;
  266. X    sqp->unsafe = FALSE;
  267. X    } else {
  268. X    sqp->unsafe = ! sqp->unsafe;
  269. X    sqp->safe = FALSE;
  270. X    }
  271. X    DrawSquare(suspect);
  272. X}
  273. X
  274. X
  275. X/*
  276. X * try to move to a certain board coordinate
  277. X */
  278. Xvoid 
  279. XDoMove(dest)
  280. X    BoardCoordinate * dest;
  281. X{
  282. X    register int y, x;
  283. X    register Square * sqp;
  284. X
  285. X    /*
  286. X     * if not adjacent to or equal to our current position
  287. X     * or the destination has been marked unsafe, ignore the move 
  288. X     */
  289. X    if (abs(dest->x - (x = PlayerLocation.x)) > 1
  290. X    || abs(dest->y - (y = PlayerLocation.y)) > 1
  291. X    || (dest->x == PlayerLocation.x && dest->y == PlayerLocation.y)
  292. X    || MainBoard[dest->y][dest->x].unsafe)
  293. X    return;
  294. X    /*
  295. X     * step off our current square
  296. X     */
  297. X    MainBoard[y][x].occupied = FALSE;
  298. X    DrawSquare(&PlayerLocation);
  299. X    sqp = &MainBoard[dest->y][dest->x];
  300. X    /*
  301. X     * if we stepped on a mine, blow him up
  302. X     */
  303. X    if (sqp->mined) {
  304. X    GameOver = TRUE;
  305. X    Message("You just exploded");
  306. X    DrawBoard();
  307. X    }
  308. X    /*
  309. X     * else if this is home, render congratulations
  310. X     */
  311. X    else if (dest->x == SIDE_SIZE-1 && dest->y == SIDE_SIZE-1) {
  312. X    PlayerLocation = * dest;
  313. X    sqp->traversed = sqp->occupied = TRUE;
  314. X    GameOver = TRUE;
  315. X    Message("You made it!");
  316. X    DrawBoard();
  317. X    }
  318. X    /*
  319. X     * else move onto the new square
  320. X     */
  321. X    else {
  322. X    PlayerLocation = * dest;
  323. X    sqp->traversed = sqp->occupied = TRUE;
  324. X    DrawSquare(dest);
  325. X    Message(MineWarningMessage());
  326. X    }
  327. X}
  328. X
  329. X/*
  330. X * return a pointer to the warning message
  331. X */
  332. Xchar *
  333. XMineWarningMessage()
  334. X{
  335. X    static char warning[128];
  336. X    register int x, y;
  337. X    int minesFound;
  338. X
  339. X    minesFound = 0;
  340. X    for (x = PlayerLocation.x - 1 ; x <= PlayerLocation.x + 1 ; x++) {
  341. X    for (y = PlayerLocation.y - 1 ; y <= PlayerLocation.y + 1 ; y++) {
  342. X        if (x >= 0 && x < SIDE_SIZE && y >= 0 && y < SIDE_SIZE && MainBoard[y][x].mined)
  343. X        minesFound++;
  344. X    }
  345. X    }
  346. X    sprintf(warning, "%d mine(s) nearby", minesFound);
  347. X    return(warning);
  348. X}
  349. X
  350. END_OF_board.c
  351. if test 4101 -ne `wc -c <board.c`; then
  352.     echo shar: \"board.c\" unpacked with wrong size!
  353. fi
  354. # end of overwriting check
  355. fi
  356. if test -f boardsw.c -a "${1}" != "-c" ; then 
  357.   echo shar: Will not over-write existing file \"boardsw.c\"
  358. else
  359. echo shar: Extracting \"boardsw.c\" \(5429 characters\)
  360. sed "s/^X//" >boardsw.c <<'END_OF_boardsw.c'
  361. X/*
  362. X * handle the board subwindow 
  363. X *
  364. X * Copyright (c) 1987 Tom Anderson; 20831 Frank Waters Road;
  365. X * Stanwood, WA  98282.   All rights reserved.
  366. X */
  367. Xstatic char copyright[] = "Copyright 1987 Tom Anderson";
  368. X
  369. X#include <stdio.h>
  370. X#include <suntool/tool_hs.h>
  371. X#include <suntool/panel.h>
  372. X#include <suntool/gfxsw.h>
  373. X#include <sunwindow/win_cursor.h>
  374. X#include <sys/resource.h>
  375. X#include <sys/ioctl.h>
  376. X#include <strings.h>
  377. X
  378. X#include "mines.h"
  379. X
  380. X/*
  381. X * cross-hairs cursor
  382. X */
  383. Xstatic short CrosshairsImage[] = {
  384. X#include "crosshairs.cursor"
  385. X};
  386. XDEFINE_CURSOR_FROM_IMAGE(CrosshairsCursor, 8, 8, PIX_SRC^PIX_DST, CrosshairsImage);
  387. X
  388. X/*
  389. X * square pixrects
  390. X */
  391. Xunsigned short WhiteSquareImage[] = {
  392. X#include "whiteSquare.icon"
  393. X};
  394. Xmpr_static(WhiteSquarePR, 64, 64, 1, WhiteSquareImage);
  395. X
  396. Xunsigned short BlackSquareImage[] = {
  397. X#include "blackSquare.icon"
  398. X};
  399. Xmpr_static(BlackSquarePR, 64, 64, 1, BlackSquareImage);
  400. X
  401. Xunsigned short PlayerSquareImage[] = {
  402. X#include "playerSquare.icon"
  403. X};
  404. Xmpr_static(PlayerSquarePR, 64, 64, 1, PlayerSquareImage);
  405. X
  406. Xunsigned short MineSquareImage[] = {
  407. X#include "mineSquare.icon"
  408. X};
  409. Xmpr_static(MineSquarePR, 64, 64, 1, MineSquareImage);
  410. X
  411. Xunsigned short SafeSquareImage[] = {
  412. X#include "safeSquare.icon"
  413. X};
  414. Xmpr_static(SafeSquarePR, 64, 64, 1, SafeSquareImage);
  415. X
  416. X/* board subwindow handles */
  417. Xstruct toolsw * BoardSW;
  418. Xstruct gfxsubwindow * Board;
  419. X
  420. X/* square sizes */
  421. Xint SquareWidth = 32, SquareHeight = 32;
  422. X/* icon offsets */
  423. Xstruct pr_pos IconOffset = { 32, 32 };
  424. X
  425. X/*
  426. X * board sigwinch handler 
  427. X */
  428. X/*ARGSUSED*/
  429. XboardSigwinch(sw)
  430. X    caddr_t sw;
  431. X{
  432. X    gfxsw_interpretesigwinch(Board);
  433. X    gfxsw_handlesigwinch(Board);
  434. X    if (Board->gfx_flags & GFX_RESTART) {
  435. X    Board->gfx_flags &= ~ GFX_RESTART;
  436. X    DrawBoard();
  437. X    }
  438. X}
  439. X
  440. X/*
  441. X * map a mouse coordinate to a board coordinate
  442. X */
  443. Xvoid
  444. XmapMouseToBoard(mlocp, blocp)
  445. X    struct pr_pos * mlocp;
  446. X    BoardCoordinate * blocp;
  447. X{
  448. X    blocp->x = mlocp->x / (SquareWidth-1);
  449. X    blocp->y = mlocp->y / (SquareHeight-1);
  450. X}
  451. X
  452. X/* 
  453. X * map a board coordinate to a mouse coordinate
  454. X */
  455. Xvoid
  456. XmapBoardToMouse(blocp, mlocp)
  457. X    BoardCoordinate * blocp;
  458. X    struct pr_pos * mlocp;
  459. X{
  460. X    mlocp->x = blocp->x * (SquareWidth-1) - 1;
  461. X    mlocp->y = blocp->y * (SquareHeight-1) - 1;
  462. X}
  463. X
  464. X/*
  465. X * board select() handler 
  466. X */
  467. X/*ARGSUSED*/
  468. XboardSelected(nullsw, ibits, obits, ebits, timer)
  469. X    caddr_t * nullsw;
  470. X    int * ibits, * obits, * ebits;
  471. X    struct timeval ** timer;
  472. X{
  473. X    struct inputevent ie;
  474. X    struct pr_pos mloc;
  475. X    BoardCoordinate bloc;
  476. X
  477. X    /*
  478. X     * read the input event
  479. X     */
  480. X    if (input_readevent(BoardSW->ts_windowfd, &ie) == -1) {
  481. X    perror("input failed");
  482. X    abort();
  483. X    }
  484. X    if (win_inputposevent(&ie)) { 
  485. X    switch(ie.ie_code) {
  486. X    /*
  487. X     * if it is an attempt to move
  488. X     */
  489. X    case MS_LEFT:
  490. X        mloc.x = ie.ie_locx; mloc.y = ie.ie_locy;
  491. X        mapMouseToBoard(&mloc, &bloc);
  492. X        DoMove(&bloc);
  493. X        break;
  494. X    /*
  495. X     * else if he is toggling a square's unsafe marking 
  496. X     */
  497. X    case MS_MIDDLE:
  498. X        mloc.x = ie.ie_locx; mloc.y = ie.ie_locy;
  499. X        mapMouseToBoard(&mloc, &bloc);
  500. X        MarkSquare(&bloc, FALSE);
  501. X        break;
  502. X    /*
  503. X     * else if he is toggling a square's safe marking 
  504. X     */
  505. X    case MS_RIGHT:
  506. X        mloc.x = ie.ie_locx; mloc.y = ie.ie_locy;
  507. X        mapMouseToBoard(&mloc, &bloc);
  508. X        MarkSquare(&bloc, TRUE);
  509. X        break;
  510. X    }
  511. X    }
  512. X    * ibits = * obits = * ebits = 0;
  513. X}
  514. X
  515. X/*
  516. X * initialize the board subwindow
  517. X */
  518. Xvoid
  519. XInitBoardSW()
  520. X{
  521. X    struct inputmask mask;
  522. X    register unsigned int i;
  523. X
  524. X    /*
  525. X     * initialize the subwindow
  526. X     */
  527. X    if ((BoardSW = gfxsw_createtoolsubwindow(MinesTool, "",
  528. X    TOOL_SWEXTENDTOEDGE, 
  529. X    /* playing surface    +  victim area */
  530. X    (SquareHeight-1) * SIDE_SIZE,
  531. X    NULL)) == NULL) 
  532. X    {
  533. X    fprintf(stderr, "Can't create board subwindow\n");
  534. X    exit(1);
  535. X    }
  536. X    Board = (struct gfxsubwindow *) BoardSW->ts_data;
  537. X    gfxsw_getretained(Board); 
  538. X    BoardSW->ts_io.tio_handlesigwinch = boardSigwinch;
  539. X    BoardSW->ts_io.tio_selected = boardSelected;
  540. X    input_imnull(&mask);
  541. X    win_setinputcodebit(&mask, MS_LEFT);
  542. X    win_setinputcodebit(&mask, MS_MIDDLE);
  543. X    win_setinputcodebit(&mask, MS_RIGHT);
  544. X    win_setinputcodebit(&mask, LOC_MOVEWHILEBUTDOWN);
  545. X    win_setinputcodebit(&mask, LOC_WINEXIT);
  546. X    mask.im_flags |= IM_NEGEVENT;
  547. X    win_setinputmask(BoardSW->ts_windowfd, &mask, NULL, WIN_NULLLINK);
  548. X    win_setcursor(BoardSW->ts_windowfd, &CrosshairsCursor);
  549. X}
  550. X
  551. X/*
  552. X * draw a square
  553. X */
  554. Xvoid
  555. XDrawSquare(bloc)
  556. X    BoardCoordinate * bloc;
  557. X{
  558. X    struct pr_pos mloc;
  559. X    struct pixrect * pr;
  560. X    Square * sqp = GetSquare(bloc);
  561. X
  562. X    /* determine which pixrect to paint the square with */
  563. X    if (sqp->occupied)
  564. X    pr = &PlayerSquarePR;
  565. X    else if (sqp->traversed)
  566. X    pr = &BlackSquarePR;
  567. X    else if ( ! GameOver && sqp->unsafe || GameOver && sqp->mined)
  568. X    pr = &MineSquarePR;
  569. X    else if ( ! GameOver && sqp->safe)
  570. X    pr = &SafeSquarePR;
  571. X    else 
  572. X    pr = &WhiteSquarePR;
  573. X    /* paint the square */
  574. X    mapBoardToMouse(bloc, &mloc);
  575. X    pw_rop(Board->gfx_pixwin, 
  576. X    mloc.x, mloc.y, SquareWidth, SquareHeight, PIX_SRC, pr, IconOffset.x, IconOffset.y);
  577. X}
  578. X
  579. X/*
  580. X * draw the playing surface and victim area
  581. X */
  582. Xvoid
  583. XDrawBoard()
  584. X{
  585. X    BoardCoordinate bloc;
  586. X
  587. X    /* clear the board area */
  588. X    pw_rop(Board->gfx_pixwin,
  589. X    0, 0, Board->gfx_rect.r_width, Board->gfx_rect.r_height,
  590. X    PIX_CLR, (struct pixrect *) 0, 0, 0);
  591. X    /* draw the playing area */
  592. X    for (bloc.x = 0 ; bloc.x < SIDE_SIZE ; bloc.x++) {
  593. X    for (bloc.y = 0 ; bloc.y < SIDE_SIZE ; bloc.y++) {
  594. X        DrawSquare(&bloc);
  595. X    }
  596. X    }
  597. X}
  598. END_OF_boardsw.c
  599. if test 5429 -ne `wc -c <boardsw.c`; then
  600.     echo shar: \"boardsw.c\" unpacked with wrong size!
  601. fi
  602. # end of overwriting check
  603. fi
  604. if test -f crosshairs.cursor -a "${1}" != "-c" ; then 
  605.   echo shar: Will not over-write existing file \"crosshairs.cursor\"
  606. else
  607. echo shar: Extracting \"crosshairs.cursor\" \(193 characters\)
  608. sed "s/^X//" >crosshairs.cursor <<'END_OF_crosshairs.cursor'
  609. X/* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
  610. X */
  611. X    0x0000,0x0100,0x0100,0x0100,0x0100,0x0100,0x0000,0x7C7C,
  612. X    0x0000,0x0100,0x0100,0x0100,0x0100,0x0100,0x0000,0x0000
  613. END_OF_crosshairs.cursor
  614. if test 193 -ne `wc -c <crosshairs.cursor`; then
  615.     echo shar: \"crosshairs.cursor\" unpacked with wrong size!
  616. fi
  617. # end of overwriting check
  618. fi
  619. if test -f levelsw.c -a "${1}" != "-c" ; then 
  620.   echo shar: Will not over-write existing file \"levelsw.c\"
  621. else
  622. echo shar: Extracting \"levelsw.c\" \(1738 characters\)
  623. sed "s/^X//" >levelsw.c <<'END_OF_levelsw.c'
  624. X/*
  625. X * level display/control subwindow handling
  626. X *
  627. X * Copyright (c) 1987 Tom Anderson; 20831 Frank Waters Road;
  628. X * Stanwood, WA  98282.   All rights reserved.
  629. X */
  630. Xstatic char copyright[] = "Copyright 1987 Tom Anderson";
  631. X
  632. X#include <stdio.h>
  633. X#include <suntool/tool_hs.h>
  634. X#include <suntool/panel.h>
  635. X#include <strings.h>
  636. X
  637. X#include "mines.h"
  638. X
  639. X#define    MAX_SEND_LENGTH        60
  640. X
  641. Xstruct toolsw * LevelSW;
  642. XPanel LevelPanel;
  643. X
  644. XPanel_item ChangeLevelItem;
  645. X
  646. X/*ARGSUSED*/
  647. XlevelProc(item, event)
  648. X    Panel_item item;
  649. X    struct inputevent *event;
  650. X{
  651. X    char c[MAX_SEND_LENGTH+1];
  652. X    static int oldLevel = DEFAULT_MINE_QTY;
  653. X    int newLevel;
  654. X
  655. X    /* get the new level request text */
  656. X    strcpy(c, (char *) panel_get_value(ChangeLevelItem));
  657. X    /* set the new level text to nil */
  658. X    panel_set_value(ChangeLevelItem, "");
  659. X    if (sscanf(c, "%d", &newLevel) == 1
  660. X    && newLevel >= 0 
  661. X    && newLevel < SIDE_SIZE * SIDE_SIZE - 20) 
  662. X    oldLevel = newLevel;
  663. X    InitBoard(oldLevel);
  664. X    DrawBoard(); 
  665. X    Message(MineWarningMessage());
  666. X    sprintf(c, "[%d]", oldLevel);
  667. X    panel_set(ChangeLevelItem, 
  668. X    PANEL_LABEL_STRING, c,
  669. X    0);
  670. X}
  671. X
  672. X/*
  673. X * set up the level control subwindow
  674. X * (if we are playing against the machine, leave them out)
  675. X */
  676. Xvoid
  677. XInitLevelSW()
  678. X{
  679. X    char c[128];
  680. X
  681. X    if ((LevelSW = panel_create(MinesTool, 0)) == NULL) {
  682. X    fprintf(stderr, "Can't create level control subwindow\n");
  683. X    exit(1);
  684. X    }
  685. X    sprintf(c, "[%d]", DEFAULT_MINE_QTY);
  686. X    LevelPanel = LevelSW->ts_data;
  687. X    ChangeLevelItem = panel_create_item(LevelPanel, PANEL_TEXT,
  688. X    PANEL_LABEL_STRING, c,
  689. X    PANEL_NOTIFY_STRING, "\n\r",
  690. X    PANEL_NOTIFY_LEVEL, PANEL_SPECIFIED,
  691. X    PANEL_NOTIFY_PROC, levelProc,
  692. X    PANEL_VALUE_STORED_LENGTH, MAX_SEND_LENGTH,
  693. X    0);
  694. X    panel_fit_height(LevelPanel); 
  695. X}
  696. END_OF_levelsw.c
  697. if test 1738 -ne `wc -c <levelsw.c`; then
  698.     echo shar: \"levelsw.c\" unpacked with wrong size!
  699. fi
  700. # end of overwriting check
  701. fi
  702. if test -f main.c -a "${1}" != "-c" ; then 
  703.   echo shar: Will not over-write existing file \"main.c\"
  704. else
  705. echo shar: Extracting \"main.c\" \(1061 characters\)
  706. sed "s/^X//" >main.c <<'END_OF_main.c'
  707. X/*
  708. X * main part of the mines program
  709. X *
  710. X * Copyright (c) 1987 Tom Anderson; 20831 Frank Waters Road;
  711. X * Stanwood, WA  98282.   All rights reserved.
  712. X */
  713. Xstatic char copyright[] = "Copyright 1987 Tom Anderson";
  714. X
  715. X#include <stdio.h>
  716. X#include <strings.h>
  717. X#include <errno.h>
  718. X#include <suntool/tool_hs.h>
  719. X#include <pwd.h>
  720. X
  721. X#include "mines.h"
  722. X
  723. Xint errno;                /* global error number */
  724. X
  725. Xmain(argc, argv)
  726. X    int argc;
  727. X    char ** argv;
  728. X{
  729. X    register int i, j;
  730. X    char * cp;
  731. X
  732. X    /* randomize things a bit */
  733. X    (void) srandom((long) getpid());
  734. X    /* parse and strip out the tool-related arguments */
  735. X    ParseToolArgs(&argc, argv);
  736. X    for (i = 1 ; i < argc ; i++) {
  737. X    if (argv[i][0] == '-') {
  738. X        switch(argv[i][1]) {
  739. X        /* small (16 x 16) version */
  740. X        case 's':
  741. X        IconOffset.x = IconOffset.y = 0;
  742. X        SquareWidth = SquareHeight = 16;
  743. X        break;
  744. X        }
  745. X    }
  746. X    }
  747. X    /* initialize the board state */
  748. X    InitBoard(DEFAULT_MINE_QTY);
  749. X    /* initialize and install the tool */
  750. X    InitTool();
  751. X    tool_install(MinesTool);
  752. X    /* now play the game */
  753. X    RunTool();
  754. X}
  755. X
  756. END_OF_main.c
  757. if test 1061 -ne `wc -c <main.c`; then
  758.     echo shar: \"main.c\" unpacked with wrong size!
  759. fi
  760. # end of overwriting check
  761. fi
  762. if test -f mineSquare.icon -a "${1}" != "-c" ; then 
  763.   echo shar: Will not over-write existing file \"mineSquare.icon\"
  764. else
  765. echo shar: Extracting \"mineSquare.icon\" \(1933 characters\)
  766. sed "s/^X//" >mineSquare.icon <<'END_OF_mineSquare.icon'
  767. X/* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16
  768. X */
  769. X    0xFFFF,0x0000,0x0000,0x0000,0x8101,0x0000,0x0000,0x0000,
  770. X    0x9201,0x0000,0x0000,0x0000,0x8041,0x0000,0x0000,0x0000,
  771. X    0x8481,0x0000,0x0000,0x0000,0xB401,0x0000,0x0000,0x0000,
  772. X    0x8201,0x0000,0x0000,0x0000,0x93C1,0x0000,0x0000,0x0000,
  773. X    0xA3E1,0x0000,0x0000,0x0000,0x87F1,0x0000,0x0000,0x0000,
  774. X    0x87F1,0x0000,0x0000,0x0000,0x87F1,0x0000,0x0000,0x0000,
  775. X    0x83E1,0x0000,0x0000,0x0000,0x81C1,0x0000,0x0000,0x0000,
  776. X    0x8001,0x0000,0x0000,0x0000,0xFFFF,0x0000,0x0000,0x0000,
  777. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  778. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  779. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  780. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  781. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  782. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  783. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  784. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  785. X    0x0000,0x0000,0xFFFF,0xFFFF,0x0000,0x0000,0x8000,0x0001,
  786. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  787. X    0x0000,0x0000,0x8180,0x0001,0x0000,0x0000,0x8540,0x0001,
  788. X    0x0000,0x0000,0x840C,0x0001,0x0000,0x0000,0xA024,0x0001,
  789. X    0x0000,0x0000,0x9C90,0x0001,0x0000,0x0000,0x8500,0x0001,
  790. X    0x0000,0x0000,0x8100,0x0001,0x0000,0x0000,0x8100,0x0001,
  791. X    0x0000,0x0000,0xA0E3,0xE001,0x0000,0x0000,0x9CF7,0xF801,
  792. X    0x0000,0x0000,0x80FB,0xFC01,0x0000,0x0000,0x807B,0xFE01,
  793. X    0x0000,0x0000,0x803B,0xFF01,0x0000,0x0000,0x8047,0xFF01,
  794. X    0x0000,0x0000,0x80FF,0xFF81,0x0000,0x0000,0x80FF,0xFF81,
  795. X    0x0000,0x0000,0x80FF,0xFF81,0x0000,0x0000,0x80FF,0xFF81,
  796. X    0x0000,0x0000,0x80FF,0xFF81,0x0000,0x0000,0x807F,0xFF01,
  797. X    0x0000,0x0000,0x807F,0xFF01,0x0000,0x0000,0x803F,0xFE01,
  798. X    0x0000,0x0000,0x801F,0xFC01,0x0000,0x0000,0x800F,0xF801,
  799. X    0x0000,0x0000,0x8003,0xE001,0x0000,0x0000,0x8000,0x0001,
  800. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0xFFFF,0xFFFF
  801. END_OF_mineSquare.icon
  802. if test 1933 -ne `wc -c <mineSquare.icon`; then
  803.     echo shar: \"mineSquare.icon\" unpacked with wrong size!
  804. fi
  805. # end of overwriting check
  806. fi
  807. if test -f mines.h -a "${1}" != "-c" ; then 
  808.   echo shar: Will not over-write existing file \"mines.h\"
  809. else
  810. echo shar: Extracting \"mines.h\" \(1151 characters\)
  811. sed "s/^X//" >mines.h <<'END_OF_mines.h'
  812. X/*
  813. X * mines header
  814. X *
  815. X * Copyright (c) 1987 Tom Anderson; 20831 Frank Waters Road;
  816. X * Stanwood, WA  98282.   All rights reserved.
  817. X */
  818. X
  819. X#define BOOL             int
  820. X#ifndef TRUE
  821. X#define TRUE            1
  822. X#endif
  823. X#ifndef FALSE
  824. X#define FALSE            0
  825. X#endif
  826. X
  827. X/*
  828. X * number of board squares per side 
  829. X */
  830. X#define    SIDE_SIZE        16
  831. X
  832. X/*
  833. X * default number of mines
  834. X */
  835. X#define    DEFAULT_MINE_QTY    20
  836. X
  837. X/*
  838. X * board coordinates
  839. X */
  840. Xtypedef struct {
  841. X    int x;
  842. X    int y;
  843. X} BoardCoordinate;
  844. X
  845. X/*
  846. X * square state
  847. X */
  848. Xtypedef struct {
  849. X    BOOL traversed;        /* has the poor soul stepped here? */
  850. X    BOOL mined;            /* is this square mined? */
  851. X    BOOL occupied;        /* is this square occupied? */
  852. X    BOOL unsafe;        /* has the player determined a mine here? */
  853. X    BOOL safe;            /* has the player determined no mines here? */
  854. X} Square;
  855. X
  856. Xextern void InitBoard(), DoMove(), InitBoardSW(), DrawSquare(),
  857. X    DrawBoard(), InitLevelSW(), InitMsgSW(), Message(),
  858. X    ParseToolArgs(), InitTool(), RunTool(), MarkSquare();
  859. Xextern Square * GetSquare();
  860. Xextern struct tool * MinesTool;
  861. Xextern char * MineWarningMessage();
  862. Xextern BOOL GameOver;
  863. Xextern struct pr_pos IconOffset;
  864. Xextern int SquareWidth, SquareHeight;
  865. END_OF_mines.h
  866. if test 1151 -ne `wc -c <mines.h`; then
  867.     echo shar: \"mines.h\" unpacked with wrong size!
  868. fi
  869. # end of overwriting check
  870. fi
  871. if test -f mines.icon -a "${1}" != "-c" ; then 
  872.   echo shar: Will not over-write existing file \"mines.icon\"
  873. else
  874. echo shar: Extracting \"mines.icon\" \(1933 characters\)
  875. sed "s/^X//" >mines.icon <<'END_OF_mines.icon'
  876. X/* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16
  877. X */
  878. X    0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  879. X    0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xE000,0x0000,0x0000,0x0007,
  880. X    0xE000,0x3800,0x0000,0x0007,0xE000,0x1C60,0x075D,0x4007,
  881. X    0xE005,0x8760,0x0251,0x8007,0xE003,0x9B20,0x025D,0x4007,
  882. X    0xE000,0x4100,0x0000,0x0007,0xE000,0x7F60,0x00EB,0xA807,
  883. X    0xE000,0x0AC0,0x004A,0x3007,0xE000,0xE440,0x004B,0xA807,
  884. X    0xE001,0xC6F0,0x0000,0x0007,0xE000,0x0620,0x001D,0x7507,
  885. X    0xE000,0x0600,0x0009,0x4607,0xE000,0x0C00,0x0009,0x7507,
  886. X    0xE000,0x1800,0x0000,0x0007,0xE000,0x3000,0x0000,0x0007,
  887. X    0xE000,0x6000,0x0001,0x2407,0xE000,0xC00F,0xE000,0x0007,
  888. X    0xE000,0xC03F,0xFC00,0x0007,0xE000,0xC0FF,0xFF00,0x0007,
  889. X    0xE000,0x79FF,0xFFC0,0x0007,0xE000,0x7CFF,0xF3E2,0x4007,
  890. X    0xE000,0x747F,0xEDF1,0x2007,0xE000,0x6D3F,0xD4F8,0x9007,
  891. X    0xE000,0x3B9F,0xFB7C,0x0007,0xE000,0x07CF,0xF77E,0x0007,
  892. X    0xE000,0xCFCF,0xFFFF,0x0007,0xE000,0xE7CF,0xFFFF,0x0007,
  893. X    0xE001,0xF39F,0xFFFF,0x8007,0xE001,0xF81F,0xFFFF,0x8007,
  894. X    0xE001,0xFC7F,0xFFFF,0xC007,0xE003,0xFFFF,0xFFFF,0xC007,
  895. X    0xE003,0xFFFF,0xFFFF,0xE007,0xE003,0xFFFF,0xFFFF,0xE007,
  896. X    0xE003,0xFFFF,0xFFFF,0xE007,0xE003,0xFFFF,0xFFFF,0xE007,
  897. X    0xE003,0xFFFF,0xFFFF,0xE007,0xE003,0xFFFF,0xFFFF,0xE007,
  898. X    0xE003,0xFFFF,0xFFFF,0xE007,0xE003,0xFFFF,0xFFFF,0xE007,
  899. X    0xE001,0xFFFF,0xFFFF,0xE007,0xE009,0xFFFF,0xFFFF,0xC007,
  900. X    0xE008,0xFFFF,0xFFFF,0xC007,0xE024,0xFFFF,0xFFFF,0xC007,
  901. X    0xE022,0x7FFF,0xFFDF,0x8007,0xE010,0x7FFF,0xFFAB,0x8007,
  902. X    0xE008,0x3FFF,0xFF77,0x0007,0xE000,0x1FFF,0xFFAE,0x0007,
  903. X    0xE000,0x0FFF,0xFFFC,0x0007,0xE000,0x07FF,0xFFF8,0x0007,
  904. X    0xE000,0x03FF,0xFFF0,0x0007,0xE000,0x00FF,0xFFC0,0x0007,
  905. X    0xE000,0x007F,0xFF80,0x0007,0xE000,0x001F,0xFC00,0x0007,
  906. X    0xE000,0x0000,0x0000,0x0007,0xE000,0x0000,0x0000,0x0007,
  907. X    0xE000,0x0000,0x0000,0x0007,0xE000,0x0000,0x0000,0x0007,
  908. X    0xE000,0x0000,0x0000,0x0007,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
  909. X    0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF
  910. END_OF_mines.icon
  911. if test 1933 -ne `wc -c <mines.icon`; then
  912.     echo shar: \"mines.icon\" unpacked with wrong size!
  913. fi
  914. # end of overwriting check
  915. fi
  916. if test -f msgsw.c -a "${1}" != "-c" ; then 
  917.   echo shar: Will not over-write existing file \"msgsw.c\"
  918. else
  919. echo shar: Extracting \"msgsw.c\" \(973 characters\)
  920. sed "s/^X//" >msgsw.c <<'END_OF_msgsw.c'
  921. X/*
  922. X * message subwindow handling
  923. X *
  924. X * Copyright (c) 1987 Tom Anderson; 20831 Frank Waters Road;
  925. X * Stanwood, WA  98282.   All rights reserved.
  926. X */
  927. Xstatic char copyright[] = "Copyright 1987 Tom Anderson";
  928. X
  929. X#include <stdio.h>
  930. X#include <ctype.h>
  931. X#include <suntool/tool_hs.h>
  932. X#include <suntool/panel.h>
  933. X#include <strings.h>
  934. X
  935. X#include "mines.h"
  936. X
  937. Xstruct toolsw * MessageSW;
  938. XPanel MessagePanel;
  939. X
  940. XPanel_item MessageItem;
  941. X
  942. X/*
  943. X * set up the message subwindow
  944. X */
  945. Xvoid
  946. XInitMsgSW()
  947. X{
  948. X    if ((MessageSW = panel_create(MinesTool, 0)) == NULL) {
  949. X    fprintf(stderr, "Can't create message panel\n");
  950. X    exit(1);
  951. X    }
  952. X    MessagePanel = MessageSW->ts_data;
  953. X    /* create the message panel item */
  954. X    MessageItem = panel_create_item(MessagePanel, PANEL_MESSAGE,
  955. X    PANEL_LABEL_STRING, MineWarningMessage(),
  956. X    PANEL_SHOW_ITEM, TRUE,
  957. X    0);
  958. X    panel_fit_height(MessagePanel); 
  959. X}
  960. X
  961. Xvoid 
  962. XMessage(cp)
  963. X    char * cp;
  964. X{
  965. X    panel_set(MessageItem,
  966. X    PANEL_LABEL_STRING, cp,
  967. X    PANEL_SHOW_ITEM, TRUE,
  968. X    0);
  969. X}
  970. END_OF_msgsw.c
  971. if test 973 -ne `wc -c <msgsw.c`; then
  972.     echo shar: \"msgsw.c\" unpacked with wrong size!
  973. fi
  974. # end of overwriting check
  975. fi
  976. if test -f playerSquare.icon -a "${1}" != "-c" ; then 
  977.   echo shar: Will not over-write existing file \"playerSquare.icon\"
  978. else
  979. echo shar: Extracting \"playerSquare.icon\" \(1933 characters\)
  980. sed "s/^X//" >playerSquare.icon <<'END_OF_playerSquare.icon'
  981. X/* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16
  982. X */
  983. X    0xFFFF,0x0000,0x0000,0x0000,0x8001,0x0000,0x0000,0x0000,
  984. X    0x8081,0x0000,0x0000,0x0000,0x81C1,0x0000,0x0000,0x0000,
  985. X    0x81C1,0x0000,0x0000,0x0000,0x8081,0x0000,0x0000,0x0000,
  986. X    0x8081,0x0000,0x0000,0x0000,0x83E1,0x0000,0x0000,0x0000,
  987. X    0x8491,0x0000,0x0000,0x0000,0x8081,0x0000,0x0000,0x0000,
  988. X    0x81C1,0x0000,0x0000,0x0000,0x81C1,0x0000,0x0000,0x0000,
  989. X    0x8221,0x0000,0x0000,0x0000,0x8221,0x0000,0x0000,0x0000,
  990. X    0x8001,0x0000,0x0000,0x0000,0xFFFF,0x0000,0x0000,0x0000,
  991. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  992. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  993. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  994. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  995. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  996. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  997. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  998. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  999. X    0x0000,0x0000,0xFFFF,0xFFFF,0x0000,0x0000,0x8000,0x0001,
  1000. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  1001. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  1002. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8003,0x8001,
  1003. X    0x0000,0x0000,0x8004,0x4001,0x0000,0x0000,0x8004,0x4001,
  1004. X    0x0000,0x0000,0x8004,0x4001,0x0000,0x0000,0x8003,0x8001,
  1005. X    0x0000,0x0000,0x8001,0x0001,0x0000,0x0000,0x8001,0x0001,
  1006. X    0x0000,0x0000,0x8001,0x0001,0x0000,0x0000,0x800F,0xE001,
  1007. X    0x0000,0x0000,0x8001,0x0001,0x0000,0x0000,0x8001,0x0001,
  1008. X    0x0000,0x0000,0x8001,0x0001,0x0000,0x0000,0x8001,0x0001,
  1009. X    0x0000,0x0000,0x8001,0x0001,0x0000,0x0000,0x8001,0x0001,
  1010. X    0x0000,0x0000,0x8001,0x0001,0x0000,0x0000,0x8002,0x8001,
  1011. X    0x0000,0x0000,0x8004,0x4001,0x0000,0x0000,0x8004,0x4001,
  1012. X    0x0000,0x0000,0x8008,0x2001,0x0000,0x0000,0x8010,0x1001,
  1013. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  1014. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0xFFFF,0xFFFF
  1015. END_OF_playerSquare.icon
  1016. if test 1933 -ne `wc -c <playerSquare.icon`; then
  1017.     echo shar: \"playerSquare.icon\" unpacked with wrong size!
  1018. fi
  1019. # end of overwriting check
  1020. fi
  1021. if test -f safeSquare.icon -a "${1}" != "-c" ; then 
  1022.   echo shar: Will not over-write existing file \"safeSquare.icon\"
  1023. else
  1024. echo shar: Extracting \"safeSquare.icon\" \(1933 characters\)
  1025. sed "s/^X//" >safeSquare.icon <<'END_OF_safeSquare.icon'
  1026. X/* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16
  1027. X */
  1028. X    0xFFFF,0x0000,0x0000,0x0000,0x8001,0x0000,0x0000,0x0000,
  1029. X    0x8001,0x0000,0x0000,0x0000,0x8001,0x0000,0x0000,0x0000,
  1030. X    0x800D,0x0000,0x0000,0x0000,0x801D,0x0000,0x0000,0x0000,
  1031. X    0x803D,0x0000,0x0000,0x0000,0x8071,0x0000,0x0000,0x0000,
  1032. X    0x8061,0x0000,0x0000,0x0000,0x98C1,0x0000,0x0000,0x0000,
  1033. X    0x8D81,0x0000,0x0000,0x0000,0x8701,0x0000,0x0000,0x0000,
  1034. X    0x8201,0x0000,0x0000,0x0000,0x8201,0x0000,0x0000,0x0000,
  1035. X    0x8001,0x0000,0x0000,0x0000,0xFFFF,0x0000,0x0000,0x0000,
  1036. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1037. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1038. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1039. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1040. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1041. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1042. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1043. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1044. X    0x0000,0x0000,0xFFFF,0xFFFF,0x0000,0x0000,0x8000,0x0001,
  1045. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  1046. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  1047. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  1048. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  1049. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x4001,
  1050. X    0x0000,0x0000,0x8000,0x4001,0x0000,0x0000,0x801C,0x4801,
  1051. X    0x0000,0x0000,0x8022,0x5001,0x0000,0x0000,0x8022,0x6001,
  1052. X    0x0000,0x0000,0x8022,0x6001,0x0000,0x0000,0x8022,0x5001,
  1053. X    0x0000,0x0000,0x8022,0x4801,0x0000,0x0000,0x801C,0x4401,
  1054. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  1055. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  1056. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  1057. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  1058. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  1059. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0xFFFF,0xFFFF
  1060. END_OF_safeSquare.icon
  1061. if test 1933 -ne `wc -c <safeSquare.icon`; then
  1062.     echo shar: \"safeSquare.icon\" unpacked with wrong size!
  1063. fi
  1064. # end of overwriting check
  1065. fi
  1066. if test -f tool.c -a "${1}" != "-c" ; then 
  1067.   echo shar: Will not over-write existing file \"tool.c\"
  1068. else
  1069. echo shar: Extracting \"tool.c\" \(2847 characters\)
  1070. sed "s/^X//" >tool.c <<'END_OF_tool.c'
  1071. X/*
  1072. X * handle the tool environment 
  1073. X *
  1074. X * Copyright (c) 1987 Tom Anderson; 20831 Frank Waters Road;
  1075. X * Stanwood, WA  98282.   All rights reserved.
  1076. X */
  1077. Xstatic char copyright[] = "Copyright 1987 Tom Anderson";
  1078. X
  1079. X#include <stdio.h>
  1080. X#include <suntool/tool_hs.h>
  1081. X#include <suntool/panel.h>
  1082. X#include <suntool/gfxsw.h>
  1083. X#include <sys/resource.h>
  1084. X#include <sys/ioctl.h>
  1085. X#include <strings.h>
  1086. X
  1087. X#include "mines.h"
  1088. X
  1089. Xstruct tool * MinesTool;
  1090. Xchar ** ToolAttrs = (char **) NULL;
  1091. Xchar * ToolName;
  1092. X
  1093. X/*
  1094. X * iconic form of window
  1095. X */
  1096. Xunsigned short IconImage[] = {
  1097. X#include "mines.icon"
  1098. X};
  1099. X
  1100. XDEFINE_ICON_FROM_IMAGE(WindowIcon, IconImage);
  1101. X
  1102. Xsigwinched()
  1103. X{
  1104. X    tool_sigwinch(MinesTool);
  1105. X}
  1106. X
  1107. X/*
  1108. X * parse the tool args.
  1109. X */
  1110. Xvoid 
  1111. XParseToolArgs(argc, argv)
  1112. X    int *argc;
  1113. X    char **argv;
  1114. X{
  1115. X    ToolName = argv[0];
  1116. X    (*argc)--;
  1117. X    argv++;
  1118. X    if (tool_parse_all(argc, argv, &ToolAttrs, ToolName) == -1) {
  1119. X    tool_usage(ToolName);
  1120. X    exit(1);
  1121. X    }
  1122. X    (*argc)++;
  1123. X}
  1124. X
  1125. X/*
  1126. X * set up the tool environment
  1127. X */
  1128. Xvoid
  1129. XInitTool()
  1130. X{
  1131. X    register unsigned int height;
  1132. X    register struct toolsw * twsp;
  1133. X
  1134. X    if ((MinesTool = tool_make( 
  1135. X    WIN_LABEL, ToolName,
  1136. X    WIN_ICON, &WindowIcon, 
  1137. X    WIN_ATTR_LIST, ToolAttrs,
  1138. X    WIN_WIDTH, SIDE_SIZE * (SquareWidth-1) + 2 * tool_borderwidth(MinesTool) - 1,
  1139. X    /*
  1140. X     * NOTE: The following line was unnecessary in Sun release 2.2,
  1141. X     * but is necessary in release 3.0.  For some unknown reason, the
  1142. X     * call to tool_set_attributes following the call to InitBoardSW
  1143. X     * now fails to uncover the board area that was obscured by the 
  1144. X     * default tool height being too small (note that the tool has not 
  1145. X     * been installed yet).
  1146. X     */
  1147. X    WIN_HEIGHT, 2000,
  1148. X    0)) == (struct tool *) NULL) 
  1149. X    {
  1150. X    fputs("Can't make tool\n", stderr);
  1151. X    exit(1);
  1152. X    }
  1153. X    tool_free_attribute_list(ToolAttrs);
  1154. X    /* initialize the subwindows */
  1155. X    InitLevelSW();
  1156. X    InitMsgSW();
  1157. X    InitBoardSW();
  1158. X    /* 
  1159. X     * add up subwindow heights and force the tool to the resulting size 
  1160. X     */
  1161. X    height = tool_stripeheight(MinesTool) + tool_borderwidth(MinesTool) - tool_subwindowspacing(MinesTool);
  1162. X    for (twsp = MinesTool->tl_sw ; twsp != (struct toolsw *) 0 ; twsp = twsp->ts_next) 
  1163. X    height += twsp->ts_height + tool_subwindowspacing(MinesTool);
  1164. X    /*
  1165. X     * NOTE: under 2.2, the above calculation yielded the correct height.
  1166. X     * under 3.0, we need to add a few pixels to make it come out right (the
  1167. X     * reason is not yet known).
  1168. X     */
  1169. X    height += 2;
  1170. X    tool_set_attributes(MinesTool, WIN_HEIGHT, height, 0); 
  1171. X    signal(SIGWINCH, sigwinched);
  1172. X}
  1173. X
  1174. Xvoid
  1175. XRunTool()
  1176. X{
  1177. X    /*
  1178. X     * NOTE: this is another difference between release 2.2 and 3.0:
  1179. X     * in release 2.2, the SIGWINCH handler would get called once at the
  1180. X     * outset to draw the board area; in release 3.0, this doesn't happen.
  1181. X     */
  1182. X    DrawBoard();
  1183. X    tool_select(MinesTool, 0);
  1184. X    tool_destroy(MinesTool);
  1185. X}
  1186. X
  1187. END_OF_tool.c
  1188. if test 2847 -ne `wc -c <tool.c`; then
  1189.     echo shar: \"tool.c\" unpacked with wrong size!
  1190. fi
  1191. # end of overwriting check
  1192. fi
  1193. if test -f whiteSquare.icon -a "${1}" != "-c" ; then 
  1194.   echo shar: Will not over-write existing file \"whiteSquare.icon\"
  1195. else
  1196. echo shar: Extracting \"whiteSquare.icon\" \(1933 characters\)
  1197. sed "s/^X//" >whiteSquare.icon <<'END_OF_whiteSquare.icon'
  1198. X/* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16
  1199. X */
  1200. X    0xFFFF,0x0000,0x0000,0x0000,0x8001,0x0000,0x0000,0x0000,
  1201. X    0x8001,0x0000,0x0000,0x0000,0x8001,0x0000,0x0000,0x0000,
  1202. X    0x8001,0x0000,0x0000,0x0000,0x8001,0x0000,0x0000,0x0000,
  1203. X    0x8001,0x0000,0x0000,0x0000,0x8001,0x0000,0x0000,0x0000,
  1204. X    0x8001,0x0000,0x0000,0x0000,0x8001,0x0000,0x0000,0x0000,
  1205. X    0x8001,0x0000,0x0000,0x0000,0x8001,0x0000,0x0000,0x0000,
  1206. X    0x8001,0x0000,0x0000,0x0000,0x8001,0x0000,0x0000,0x0000,
  1207. X    0x8001,0x0000,0x0000,0x0000,0xFFFF,0x0000,0x0000,0x0000,
  1208. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1209. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1210. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1211. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1212. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1213. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1214. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1215. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1216. X    0x0000,0x0000,0xFFFF,0xFFFF,0x0000,0x0000,0x8000,0x0001,
  1217. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  1218. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  1219. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  1220. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  1221. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  1222. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  1223. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  1224. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  1225. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  1226. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  1227. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  1228. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  1229. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  1230. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0x8000,0x0001,
  1231. X    0x0000,0x0000,0x8000,0x0001,0x0000,0x0000,0xFFFF,0xFFFF
  1232. END_OF_whiteSquare.icon
  1233. if test 1933 -ne `wc -c <whiteSquare.icon`; then
  1234.     echo shar: \"whiteSquare.icon\" unpacked with wrong size!
  1235. fi
  1236. # end of overwriting check
  1237. fi
  1238. echo shar: End of shell archive.
  1239. exit 0
  1240.